import request from 'umi-request';

export async function getProtocolPersonnelPage(params = {},type) {
  let {trainingTime, ...restParams} = params;
  let queryParams = {
    pageNum: params.current,
    pageSize: params.pageSize,
    type: type,
    ...restParams
  };
  if (trainingTime){
    queryParams.trainingStartTime = params.trainingTime[0];
    queryParams.trainingEndTime = params.trainingTime[1];
  }
  return request('/hr-ssc/api/api-admin/protocol/getProtocolPersonnelPage', {
    method: 'get',
    params: queryParams,
  }).then((res) => {
    if (res.flag) {
      const data = res.data;
      return {
        current: data.currPage,
        data: data.list,
        pageSize: data.pageSize,
        success: true,
        total: data.totalCount,
      };
    } else {
      return {};
    }
  });
}

export async function updateProtocolPersonnelStatus(params = {}) {
  return request('/hr-ssc/api/api-admin/protocol/updateProtocolPersonnelStatus', {
    method: 'get',
    params: params,
  }).then((res) => res);
}

